package StudyCode.summary.mycollection;

import java.util.BitSet;

/**
 * 版权所有 科技与人文(www.tah1986.com)
 */
public class UseBitSetToTrackFlags {
	private BitSet sked = new BitSet(365);

	private UseBitSetToTrackFlags() {
		int[] holiday = {1, 15, 50, 148, 185, 246, 281, 316, 326, 359};
		for (int aHoliday : holiday) {
			addHoliday(aHoliday);
		}
	}

	private void addHoliday(int dayToAdd) {
		sked.set(dayToAdd);
	}

	private boolean isHoliday(int dayToCheck) {
		return sked.get(dayToCheck);
	}

	public static void main(String[] arguments) {
		UseBitSetToTrackFlags cal = new UseBitSetToTrackFlags();

		try {
			int whichDay = 123;
			if (cal.isHoliday(whichDay)) {
				System.out.println(whichDay + " 号是节假日.");
			} else {
				System.out.println(whichDay + " 号不是节假日.");
			}
		} catch (NumberFormatException nfe) {
			nfe.printStackTrace();
		}

	}
}
